package com.example.mydesignmodule.zerenlian;

/**
 * @author tgw
 * @date 2021/3/1
 * @describe 责任链
 */
class ChainDutyRunMain {

    public static void main(String[] args) {
        HandleOne handleOne = new HandleOne();
        HandleTwo handleTwo = new HandleTwo();
        HandleThree handleThree = new HandleThree();

        handleOne.setDutyChainHandle(handleTwo);
        handleTwo.setDutyChainHandle(handleThree);

        handleOne.setmLevel(1);
        handleTwo.setmLevel(2);
        handleThree.setmLevel(3);

        /**相当于领导 报销 模式 组长，主管 ，老板*/
        //优先低等级有权限的先处理
        handleOne.handleRequest(1);
        handleOne.handleRequest(2);
        handleOne.handleRequest(3);

        handleTwo.handleRequest(2);
        handleTwo.handleRequest(1);
        handleTwo.handleRequest(3);

        handleThree.handleRequest(3);
        handleThree.handleRequest(1);
        handleThree.handleRequest(2);
    }
}
